package com.alibaba.citrus.cr.platform.enhance.functions.diff.sap.template;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import com.alibaba.citrus.cr.platform.enhance.functions.diff.common.constant.OrderStatusCompareWayEnum;
import com.alibaba.citrus.cr.platform.enhance.repository.model.diff.common.OrderStatusFieldDTO;

import com.epoch.app.crb2btradecenter.enums.OrderStatus;

/**
 * @author: hanguo
 * @create: 2022/02/17
 * @Description 销售子单状态对账
 */
public class SalesSubOrderStatusStandardTemplate {

    /**
     * 2 待交货状态下需要核对的字段
     */
    private static Set<OrderStatusFieldDTO> beforeDeliverySet = new HashSet<>();

    /**
     * 4 该状态有已拒绝和已完成的两种情况，对应的字段不一样 ... todo hanguo
     */
    private static Set<OrderStatusFieldDTO> completedSet = new HashSet<>();


    /**
     * 6 待推送状态下需要核对的字段
     */
    private static Set<OrderStatusFieldDTO> stayPushSet = new HashSet<>();


    /**
     * 12 待处理下状态下需要核对的字段
     */
    private static Set<OrderStatusFieldDTO> waitHandleSet = new HashSet<>();


    /**
     * 13待收货下状态下需要核对的字段
     */
    private static Set<OrderStatusFieldDTO> waitReceivingSet = new HashSet<>();




    /**
     * map
     */
    private static Map<String,Set<OrderStatusFieldDTO>> map = new HashMap<>();

    /**
     * 忽略字段集合
     */
    private static Set<String> ignoreSet = new HashSet<>();


    static {

        //2待交货
        OrderStatusFieldDTO outerOrderIdDTO2 = new OrderStatusFieldDTO();
        outerOrderIdDTO2.setTableField("outerOrderLineId");
        outerOrderIdDTO2.setCompareWay(OrderStatusCompareWayEnum.NOT_NULL.getFieldCode());
        beforeDeliverySet.add(outerOrderIdDTO2);

        OrderStatusFieldDTO orderTagDTO2 = new OrderStatusFieldDTO();
        orderTagDTO2.setTableField("orderLineTag");
        orderTagDTO2.setCompareWay(OrderStatusCompareWayEnum.SPECIAL_VALUE.getFieldCode());
        orderTagDTO2.setFieldValue("normal");
        beforeDeliverySet.add(orderTagDTO2);

        map.put(OrderStatus.BEFORE_DELIVERY.getCode().toString(),beforeDeliverySet);


//        //4已完成
        OrderStatusFieldDTO outerOrderIdDTO4 = new OrderStatusFieldDTO();
        outerOrderIdDTO4.setTableField("refuseReasonCode");
        outerOrderIdDTO4.setCompareWay(OrderStatusCompareWayEnum.NULL.getFieldCode());
        completedSet.add(outerOrderIdDTO4);

        OrderStatusFieldDTO deliveryAmountDTO4 = new OrderStatusFieldDTO();
        deliveryAmountDTO4.setTableField("deliveryAmount");
        deliveryAmountDTO4.setCompareWay(OrderStatusCompareWayEnum.NOT_NULL.getFieldCode());
        completedSet.add(deliveryAmountDTO4);

        OrderStatusFieldDTO quantityDTO4 = new OrderStatusFieldDTO();
        quantityDTO4.setTableField("quantity");
        quantityDTO4.setCompareWay(OrderStatusCompareWayEnum.NOT_NULL.getFieldCode());
        completedSet.add(quantityDTO4);

        OrderStatusFieldDTO deliveryOrderLineNoDTO4 = new OrderStatusFieldDTO();
        deliveryOrderLineNoDTO4.setTableField("features.deliveryOrderLineNo");
        deliveryOrderLineNoDTO4.setCompareWay(OrderStatusCompareWayEnum.NOT_NULL.getFieldCode());
        completedSet.add(deliveryOrderLineNoDTO4);
        map.put(OrderStatus.COMPLETED.getCode().toString(), completedSet);


        //6待推送
        OrderStatusFieldDTO outerOrderIdDTO6 = new OrderStatusFieldDTO();
        outerOrderIdDTO6.setTableField("outerOrderLineId");
        outerOrderIdDTO6.setCompareWay(OrderStatusCompareWayEnum.NULL.getFieldCode());
        stayPushSet.add(outerOrderIdDTO6);
        map.put(OrderStatus.STAY_PUSH.getCode().toString(), stayPushSet);


        //12待处理
        OrderStatusFieldDTO outerOrderIdDTO12 = new OrderStatusFieldDTO();
        outerOrderIdDTO12.setTableField("outerOrderLineId");
        outerOrderIdDTO12.setCompareWay(OrderStatusCompareWayEnum.NOT_NULL.getFieldCode());
        waitHandleSet.add(outerOrderIdDTO12);

        OrderStatusFieldDTO orderTagDTO12 = new OrderStatusFieldDTO();
        orderTagDTO12.setTableField("orderLineTag");
        orderTagDTO12.setCompareWay(OrderStatusCompareWayEnum.SPECIAL_VALUE.getFieldCode());
        orderTagDTO12.setFieldValue("exchange");
        waitHandleSet.add(orderTagDTO12);
        
        map.put(OrderStatus.WAIT_HANDLE.getCode().toString(), waitHandleSet);


        //13待收货
        OrderStatusFieldDTO outerOrderIdDTO13 = new OrderStatusFieldDTO();
        outerOrderIdDTO13.setTableField("outerOrderLineId");
        outerOrderIdDTO13.setCompareWay(OrderStatusCompareWayEnum.NOT_NULL.getFieldCode());
        waitReceivingSet.add(outerOrderIdDTO13);

        OrderStatusFieldDTO orderTagDTO13 = new OrderStatusFieldDTO();
        orderTagDTO13.setTableField("orderLineTag");
        orderTagDTO13.setCompareWay(OrderStatusCompareWayEnum.SPECIAL_VALUE.getFieldCode());
        orderTagDTO13.setFieldValue("return");
        waitReceivingSet.add(orderTagDTO13);

        map.put(OrderStatus.WAIT_RECEIVING.getCode().toString(), waitReceivingSet);




        //忽略列表
        //###############################################################//
        ignoreSet.add("features.deliveryOrderLineNo");


    }


    public static Set<OrderStatusFieldDTO> obtainTemplateFieldSet(String mainOrderStatus) {
        return map.get(mainOrderStatus);
    }

    public static Set<String> obtainIgnoreFieldSet() {
        return ignoreSet;
    }


}
